/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://github.com/mineadmin
 */

import type { MaFormItem } from "@mineadmin/form";

import { ElRadio, ElRadioGroup } from "element-plus";
import { HomeworkVo } from "@/modules/homework/api/homework";
//@ts-ignore
import QuestionOption from "../components/questionOption.vue";

export default function getFormItems(
  formType: "add" | "edit" = "add",
  t: any,
  model: HomeworkVo
): MaFormItem[] {
  if (formType === "add") {
    model.type = "question_back";
    model.mode = "custom";
  }

  return [
    {
      label: () => t("homework.title"),
      prop: "title",
      render: "input",
      renderProps: {
        placeholder: t("form.pleaseInput", { msg: t("homework.title") }),
      },
      itemProps: {
        rules: [
          {
            required: true,
            message: t("form.requiredInput", { msg: t("homework.title") }),
          },
        ],
      },
    },
    {
      label: () => t("homework.type"),
      prop: "type",
      render: () => <ElRadio label="题库" value="question_back"></ElRadio>,
      renderProps: {
        placeholder: t("form.pleaseSelect", { msg: t("homework.type") }),
      },
      itemProps: {
        rules: [
          {
            required: true,
            message: t("form.requiredSelect", { msg: t("homework.type") }),
          },
        ],
      },
    },
    {
      label: () => t("homework.remark"),
      prop: "remark",
      render: "input",
      renderProps: {
        placeholder: t("form.pleaseInput", { msg: t("homework.remark") }),
      },
      itemProps: {
        rules: [
          {
            required: true,
            message: t("form.requiredInput", { msg: t("homework.remark") }),
          },
        ],
      },
    },
    {
      label: () => t("homework.mode"),
      prop: "mode",
      render: () => (
        <ElRadioGroup>
          <ElRadio label="手动出题" value="custom"></ElRadio>
          {/* <ElRadio label="随机出题" value="random"></ElRadio> */}
        </ElRadioGroup>
      ),
      renderProps: {
        placeholder: t("form.pleaseSelect", { msg: t("homework.mode") }),
      },
      itemProps: {
        rules: [
          {
            required: true,
            message: t("form.requiredSelect", { msg: t("homework.mode") }),
          },
        ],
      },
    },
    {
      label: () => t("homework.option"),
      prop: "option",
      render: () => <QuestionOption />,
      renderProps: {
        placeholder: t("form.pleaseInput", { msg: t("homework.option") }),
        model
      },
      itemProps: {
        rules: [
          {
            required: true,
            message: t("form.requiredInput", { msg: t("homework.option") }),
          },
        ],
      },
    },
  ];
}
